home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / bsrc_p2.arc / RECVMDM7.C < prev    next >
Encoding:
C/C++ Source or Header  |  1988-11-30  |  8.2 KB  |  192 lines

  1. /*--------------------------------------------------------------------------*/
  2. /* FILE: recvmdm7.c    (MODEM7 file name receiver)                          */
  3. /*                                                                          */
  4. /*                                                                          */
  5. /*               The Opus Computer-Based Conversation System                */
  6. /*       (c) Copyright 1986, Wynn Wagner III, All Rights Reserved           */
  7. /*                                                                          */
  8. /*                                                                          */
  9. /* (MSC/4 with /Zp /Ox)                                                     */
  10. /*                                                                          */
  11. /*                                                                          */
  12. /*                                                                          */
  13. /*                                                                          */
  14. /*  This module is similar to a routine used by Opus-Cbcs (1.00).  It is    */
  15. /*  provided for your information only.  You will find routines that need   */
  16. /*  to be coded and identifiers to be resolved.                             */
  17. /*                                                                          */
  18. /*  There is absolutely no guarantee that anything here will work.  If you  */
  19. /*  break this routine, you own both pieces.                                */
  20. /*                                                                          */
  21. /*  USAGE:  You may use this material in any program with no obligation     */
  22. /*          as long as there is no charge for your program.  For more       */
  23. /*          information about commercial use, contact the "OPUSinfo HERE"   */
  24. /*          BBS (124/111).                                                  */
  25. /*                                                                          */
  26. /*                                                                          */
  27. /*--------------------------------------------------------------------------*/
  28.  
  29. #include "xfer.h"
  30. #include "com.h"
  31. #include <stdio.h>
  32.  
  33. /*--------------------------------------------------------------------------*/
  34. /* From RECVMDM7.C                                                          */
  35. /*--------------------------------------------------------------------------*/
  36. extern char  *_s_mdm7fname;
  37. extern char  *_s_mdm7giveup;
  38. extern char  *_s_mdm7idunno;
  39. extern char  *_s_mdm7chksum;
  40. extern char  *_s_mdm7nak;
  41. extern char  *_s_mdm7toolong;
  42.  
  43.  
  44.  
  45. /* ------------------------------------------------------------------------ */
  46. /* TeLink batch mode file name mini-header                                  */
  47. /* ------------------------------------------------------------------------ */
  48. int recvmdm7( fname )
  49.    char *fname;
  50.    begin
  51.       register int            i,j;
  52.       int            got_dot;
  53.       int            retbyte;
  54.       int            tries;
  55.       int            xchksum;
  56.       int            got_eot;
  57.       char          *stat     = NOTHING_msg;
  58.       char           tempname[30];
  59.  
  60.       clearbrk();    /* ww */
  61.       brk_disable(); /* ww */
  62.       XON_DISABLE(); /* ww */
  63.  
  64.       set_xy("");
  65.  
  66.       tries = got_eot = 0;
  67.  
  68.         if (PEEKBYTE()==0xffff)  SENDBYTE(NAK);
  69.  
  70.  
  71. top:
  72.    
  73.       message(NULL);
  74.  
  75.       i = got_dot = 0;
  76.       tries++;
  77.  
  78.       setmem( tempname, 30, '\0' );
  79.       setmem( fname,    30, '\0' );
  80.  
  81.       while( (CARRIER) and (tries<8) )
  82.          begin
  83.             switch ( retbyte = TIMED_READ(3) )
  84.                 begin
  85.                   case SUB :
  86.                               /*--------------------------------------------*/
  87.                               /* SUB                                        */
  88.                               /*--------------------------------------------*/
  89.                               if (!i)
  90.                                  begin
  91.                                     if (tries<4) goto top;
  92.                                     else
  93.                                        begin
  94.                                           return(0);
  95.                                        end
  96.                                  end
  97.  
  98.                               for(xchksum=SUB,i=0; tempname[i]; i++)
  99.                                  xchksum += tempname[i];
  100.                               CLEAR_INBOUND();
  101.                               SENDBYTE( xchksum );
  102.                               retbyte = TIMED_READ(5);
  103.                               if (retbyte==ACK)
  104.                                  begin
  105.                                     /*---- Gussy up the name ---------------*/
  106.                                     setmem(fname,30,'\0');
  107.                                     for(
  108.                                           i=j=got_dot=0;
  109.                                           ( (tempname[i]) and (i<30) );
  110.                                           i++
  111.                                        )
  112.                                        begin
  113.                                           if (tempname[i]=='.') got_dot=1;
  114.                                           else if ((i==8)&&(!got_dot))
  115.                                              fname[j++] = '.';
  116.                                           fname[j++] = tempname[i];
  117.                                        end
  118.  
  119.                                     /* force BBS_STATUS to overwrite line */
  120.                                     message(NULL);
  121.                                     return 1;
  122.  
  123.                                  end
  124.  
  125.                               got_eot = 0;
  126.                               SENDBYTE(NAK);
  127.                               goto top;
  128.  
  129.                   case 'u' :  /* Another error condition */
  130.                   case ACK :
  131.                               /*--------------------------------------------*/
  132.                               /* ACK                                        */
  133.                               /*--------------------------------------------*/
  134.                               goto top;
  135.  
  136.                   case EOT :  /*--------------------------------------------*/
  137.                               /* EOT                                        */
  138.                               /*--------------------------------------------*/
  139.                               stat = EOT_msg;
  140.                               SENDBYTE( ACK );
  141.                               if (got_eot>2) return 0;
  142.  
  143.                               got_eot++;
  144.                               goto top;
  145.  
  146.                   case CAN :  /*--------------------------------------------*/
  147.                               /* CAN                                        */
  148.                               /*--------------------------------------------*/
  149.                               stat = CAN_msg;
  150.                               goto fubar;
  151.  
  152.                   default  :  /*--------------------------------------------*/
  153.                               /* Default                                    */
  154.                               /*--------------------------------------------*/
  155.                               if (retbyte<' ')
  156.                                  begin
  157.  
  158.                                     if (got_eot>2) return 0;
  159.                                     else           got_eot++;
  160.  
  161.                                     CLEAR_INBOUND();
  162.  
  163.                                     SENDBYTE( NAK );
  164.                                     goto top;
  165.                                  end
  166.                               if (i >= 30)
  167.                                  begin
  168.                                     stat = _s_mdm7toolong;
  169.                                     goto fubar;
  170.                                  end
  171.                               if ((retbyte>=' ') and (retbyte<='~'))
  172.                                  begin
  173.                                     tempname[i++]= (char )retbyte;
  174.                                     putch( retbyte );
  175.                                  end
  176.                               SENDBYTE( ACK );
  177.                end /* switch */
  178.          end /* while */
  179.  
  180. fubar:
  181.  
  182.       if (tries>=16) stat = FUBAR_msg;
  183.       cputs(stat);
  184.  
  185.       return 0;
  186.  
  187.    end /* get batchname */
  188.  
  189. /* END OF FILE: recvmdm7.c */
  190.  
  191.  
  192.